// import { $put } from '@src/assets/js/authRequest'
// import { awaitWrap } from '@src/assets/js/tool'
import { Space, Tooltip } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import React from 'react'
import style from './Index.module.less'

// async function subRequest (id) {
//   const res = await $put(`/api/mgt/institution/subInstitutionAudit/${id}`, {
//     status: '待审核'
//   })
//   if (res.status !== 1) {
//     throw new Error(res.message)
//   }
//   return res.data
// }

// async function subHandle (id, refreshFn) {
//   const h = message.loading('提交中', 0)
//   const [e] = await awaitWrap(subRequest(id))
//   h()
//   if (e === null) {
//     message.success('提交成功', 1)
//     refreshFn()
//   }
// }

// 获取表格字段配置
export function getColumns () {
  return [
    {
      title: '序号',
      dataIndex: 'key',
      key: 'index',
      align: 'center',
      width: 60
    },
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
      width: 100
    },
    {
      title: '所属机构',
      dataIndex: 'pname',
      key: 'pname',
      width: 100
    },
    {
      title: '人员数',
      dataIndex: 'staff_num',
      key: 'staff_num',
      width: 100
    },
    {
      title: '仲裁员数',
      dataIndex: 'arbitrator_num',
      key: 'arbitrator_num',
      width: 100
    },
    {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      width: 100,
      render: (v, line) => {
        if (v === '审核不通过') {
          return (
            <Space size={4}>
              <span>{v}</span>
              {line.check_result && (
                <Tooltip trigger={['click']} title={line.check_result}>
                  <QuestionCircleOutlined className={style.remark} />
                </Tooltip>
              )}
            </Space>
          )
        }
        return v
      }
    },
    {
      title: '操作',
      dataIndex: 'id',
      key: 'id',
      width: 100,
      render: (v, line) => {
        return <a onClick={() => { this.setState({ visible: true, modifyData: line }) }}>{['审核通过', '审核不通过'].includes(line.status) ? '详情' : '审核'}</a>
      }
    }
  ]
}
